package bjx.com.kehu.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import bjx.com.kehu.R;

/**
 * Created by jqc on 2017/11/14.
 */

public class PersonalActivity extends BaseActivity {

    ImageView mIVBack;
    TextView mTVTitle;
    TextView mTVEvent;

    LinearLayout mLLNickName;
    LinearLayout mLLZFB;
    TextView mTVUName;
    TextView mTVNName;
    TextView mTVVipType;
    TextView mTVZFB;

    @Override
    protected void initView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_personal);
        mIVBack = getViewById(R.id.back);
        mTVTitle = getViewById(R.id.title);
        mTVTitle.setText("我的资料");
        mTVEvent = getViewById(R.id.event);
        mTVEvent.setText("保存");
        mTVEvent.setVisibility(View.GONE);

        mLLNickName = getViewById(R.id.personal_ll_nickname);
        mLLZFB = getViewById(R.id.personal_ll_zfb);
        mTVUName = getViewById(R.id.personal_tv_uname);
        mTVNName = getViewById(R.id.personal_tv_nickname);
        mTVVipType = getViewById(R.id.personal_tv_viptpye);
        mTVZFB = getViewById(R.id.personal_tv_zfb);
    }

    @Override
    protected void setListener() {
        mIVBack.setOnClickListener(this);
        mTVEvent.setOnClickListener(this);

        mLLNickName.setOnClickListener(this);
        mLLZFB.setOnClickListener(this);
    }

    @Override
    protected void processLogic(Bundle savedInstanceState) {

    }



    @Override
    protected void onResume() {
        super.onResume();
        if (userModel != null) {
            mTVUName.setText(userModel.getMobile());
            mTVNName.setText(userModel.getNickname());
            String vip = userModel.getUser_type();
            String vipStr = "";
            if (vip != null) {
                if (vip.equals("0")) {
                    vipStr += "非会员";
                } else if (vip.equals("1")) {
                    vipStr += "普通会员";
                } else if (vip.equals("2")) {
                    vipStr += "合作伙伴";
                } else if (vip.equals("3")) {
                    vipStr += "超级会员";
                }
            }
            mTVVipType.setText(vipStr);
            mTVZFB.setText(userModel.getAlipay());
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.personal_ll_nickname:
                startActivity(new Intent(mApp, UpdateUserNickNameActivity.class).addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT));
                break;
            case R.id.personal_ll_zfb:
                startActivity(new Intent(mApp, UpdateUserZFBActivity.class).addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT));
                break;
            case R.id.event:
                break;
            case R.id.back:
                finish();
                break;
            default:break;
        }
    }
}
